package leetcode;

public class Test0035 {
    public int searchInsert(int[] nums, int target) {
        if(nums==null || nums.length<=0)
            return 0;
        int start=0,end=nums.length-1;
        while (start<=end){
            int middleIndex=(start+end)/2;
            int middleValue=nums[middleIndex];
            if(middleValue==target)
                return middleIndex;
            else if(target<middleValue)
                end=middleIndex-1;
            else
                start=middleIndex+1;
        }
        System.out.println(start);
        return start;
    }
}
